<?php

/**
 * ftAlbum admin form
 *
 * @package    fantaseagroup
 * @subpackage ftAlbum
 * @author     Your name here
 */
class FtAlbumAdminForm extends BaseFtAlbumForm
{
  public function configure()
  {
       parent::configure();
    unset($this['created_by'], $this['slug'],  $this['created_at']);
    // Validator
    $this->validatorSchema['title'] = new sfValidatorString(
      array(
        'required' => true, 'max_length' => 255, 'trim'=>true),
      array(
        'invalid' => 'Tiêu đề không hợp lệ',
      	'max_length' => 'Tiêu đề quá dài',
        'required'=> 'Chưa nhập tiêu đề'
      ));

    $this->validatorSchema['header'] = new sfValidatorString(
            array('required' => false, 'max_length' => 1500, 'trim'=>true),
            array(
              'invalid' => 'Header không hợp lệ',
              'max_length' => 'Header quá dài',
              'required'=> 'Chưa nhập Header'
            ));

  }

  /**
   * Validate image - Thumbnail of service
   */
  protected function  createMediaFormForImageId() {

    // get the DmMedia form
	   $form = DmMediaForRecordForm::factory($this->object, 'image_id', 'Image', false);

	   // choose mime types allowed
	    $form->setMimeTypeWhiteList(array(
	      'image/jpeg',
              'image/png',
	      'image/gif'
	    ));

	    $form->validatorSchema['file']->setOption('max_size', 5000000);
	    unset($form['legend'], $form['author'], $form['license']);
	    $form->getWidgetSchema()
	    ->getFormFormatter()
	    ->setErrorListFormatInARow('');
	    return $form;
  }
}